package exam.service;

import exam.daoImpl.UserDaoImpl;
import exam.pojo.User;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class UserService {

    UserDaoImpl pdi = new UserDaoImpl();

    /**
     * 添加单条数据
     * @param person
     * @return
     */
    public boolean insert(User person){
        List<User> people = new ArrayList<>();
        people.add(person);
        return insert(people);
    }

    /**
     * 添加不定长形式的多条数据
     * @param person
     * @return
     */
    public boolean insert(User... person){
        List<User> people = Arrays.asList(person);
        return insert(people);
    }

    /**
     * 添加集合形式的多条数据
     * @param person
     * @return
     */
    public boolean insert(List<User> person){
        return pdi.insert(person);
    }


    public boolean update(User person){
        return pdi.update(person);
    }


    public boolean delete(String[] person) {
        return pdi.delete(person);
    }

    public List<User> getAll() throws SQLException {
        return pdi.getAll();
    }
}
